package com.biz.primus.base.vo;

import io.swagger.annotations.ApiModel;
import io.swagger.annotations.ApiModelProperty;
import lombok.AllArgsConstructor;
import lombok.Getter;
import lombok.NoArgsConstructor;
import lombok.Setter;

import javax.validation.constraints.NotNull;
import java.io.Serializable;

/**
 * ProductQuantityPair
 *
 * @author jia JKLiues
 * @date 2017年10月19日
 * @reviewer
 * @see
 */
@Getter
@Setter
@NoArgsConstructor
@AllArgsConstructor
@ApiModel("商品数量对象VO")
public class ProductQuantityPair implements Serializable {
    private static final long serialVersionUID = 8793887887864772770L;

    @ApiModelProperty("商品编码")
    @NotNull
    private String productCode;

    @ApiModelProperty("数量")
    @NotNull
    private Integer quantity;

    @Override
    public boolean equals(Object o) {
        if (this == o) return true;
        if (o == null || getClass() != o.getClass()) return false;

        ProductQuantityPair that = (ProductQuantityPair) o;

        return productCode.equals(that.getProductCode()) && quantity.equals(that.getQuantity());
    }

    @Override
    public int hashCode() {
        int result = productCode.hashCode();
        result = 31 * result + quantity.hashCode();
        return result;
    }
}